home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Sapphire Collection / Software Vault (Sapphire Collection) (Digital Impact).ISO / cdr47 / pgloader.zip / ADLIB.ASM < prev    next >
Assembly Source File  |  1994-05-28  |  5KB  |  171 lines

  1. ;--------------------------------------------------------------------
  2. ;                    SimplexAdlib Player
  3. ;--------------------------------------------------------------------
  4. ;              Copyright (C) 1993 Future Crew
  5. ;--------------------------------------------------------------------
  6. ;                        code: Psi
  7. ;                       music: Skaven
  8. ;--------------------------------------------------------------------;
  9. ; Modifications for PGRID Loader by Friar Tuck, outlined by comment  ;
  10. ; blocks                                                             ;
  11. ;--------------------------------------------------------------------;
  12. ;████████████████ Simplex Adlib Player ████████████████
  13. ;this doesn't just read raw data to output to adlib like the one
  14. ;used in the last starport intro. This player really does have
  15. ;note & instrument data it reads and processes!
  16.  
  17. ;adlib data
  18. a_musiccnt dw    0
  19. a_chdelaycnt db    9 dup(0)
  20. a_chdelay db    9 dup(0)
  21.  
  22. ;adlib player data
  23. a_inst_table LABEL BYTE
  24.         db 20h+0,20h+1,20h+2,20h+8,20h+9,20h+10,20h+16,20h+17,20h+18
  25. NTB equ 8192 ;+1024*1
  26. a_note_table LABEL WORD
  27.         dw NTB+363,NTB+385,NTB+408,NTB+432,NTB+458,NTB+485
  28.         dw NTB+514,NTB+544,NTB+577,NTB+611,NTB+647,NTB+868
  29.         ;note: a zero word is expected after this table (found in col0)
  30.  
  31. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ output data to adlib ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  32. a_lodsboutaw03: ;size optimization related entry (instrument loading)
  33.     call    a_lodsboutaw
  34.     add    ah,3
  35. a_lodsboutaw: ;size optimization related entry (instrument loading)
  36.     lodsb
  37. a_outaw PROC ;ah=reg,al=data
  38.     push    ax
  39.     push    cx
  40.     xchg    al,ah
  41.     mov    dx,388h
  42.     out    dx,al
  43.     mov    cx,7
  44.     call    a_wait
  45.     mov    dx,389h
  46.     mov    al,ah
  47.     out    dx,al
  48.     mov    cx,30
  49.     call    a_wait
  50.     pop    cx
  51.     pop    ax
  52.     ret
  53. a_wait:    in    al,dx
  54.     loop    a_wait
  55.     ret
  56. a_outaw    ENDP
  57.  
  58. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ load instrument to adlib ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  59. a_loadinstrument PROC
  60.     ;bx=channel, ds:si=offset to instrument data
  61.         mov     ah,ds:a_inst_table[bx]
  62.     mov    cx,4
  63. @@11:   call    a_lodsboutaw03
  64.     add    ah,20h-3
  65.         loop    @@11
  66.     add    ah,40h
  67.     call    a_lodsboutaw03
  68.     mov    ah,bl
  69.     add    ah,0c0h
  70.     jmp    a_lodsboutaw
  71. a_loadinstrument ENDP
  72.  
  73. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ set note on/off ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  74. a_playnote PROC
  75.     ;bx=channel, ax=data
  76.     push    bx
  77.     xchg    ah,bl
  78.     add    ah,0a0h
  79.     call    a_outaw
  80.     mov    al,bl
  81.     add    ah,010h
  82.     pop    bx
  83.     jmp    a_outaw
  84. a_playnote ENDP
  85.  
  86. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ initialize/clear/shutup adlib ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  87. a_init PROC
  88.     mov    ax,00120h
  89.     call    a_outaw
  90.     mov    ax,00800h
  91.     call    a_outaw
  92.     mov    ah,0bdh
  93.     call    a_outaw
  94.     mov    bp,9
  95.     xor    bx,bx
  96.     mov    di,OFFSET music_instruments
  97. @@12:   mov     si,ds:[di]
  98.     add    di,2
  99.     call    a_loadinstrument
  100.     xor    ax,ax
  101.     call    a_playnote
  102.     inc    bx
  103.     dec    bp
  104.         jnz     @@12
  105.     ret
  106. a_init ENDP
  107.  
  108. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ advance music one row ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  109. a_dorow PROC
  110.         ;-------------------------------;
  111.         mov     cx,24                   ;
  112.         mov     di,offset pal+222       ;
  113. ad_01:  mov     al,byte ptr cs:[di]     ;
  114.         sub     al,2                    ;
  115.         js      ad_02                   ;
  116.         mov     byte ptr cs:[di],al     ;
  117. ad_02:  inc     di                      ;
  118.         loop ad_01                      ;
  119.         ;-------------------------------;
  120. @@c:    sub     ds:a_musiccnt,1
  121.     jnc    @@0
  122.         mov     ds:a_musiccnt,music_speed
  123.     mov    cx,music_channels
  124.     mov    di,OFFSET music_patterns
  125.     xor    bx,bx
  126. @@13:   sub     ds:a_chdelaycnt[bx],1
  127.     jns    @@2
  128.         mov     si,ds:[di]
  129.     xor    ax,ax
  130.     call    a_playnote
  131.         ;-------------------------------;
  132.         push    bx                      ;
  133.         push    ax                      ;
  134.         mov     ax,bx                   ;
  135.         sal     ax,1                    ;
  136.         add     bx,ax                   ;
  137.         add     bx,222                  ;
  138.         mov     byte ptr cs:pal[bx],30  ;
  139.         mov     byte ptr cs:pal[bx+1],30;
  140.         mov     byte ptr cs:pal[bx+2],62;
  141.         pop     ax                      ;
  142.         pop     bx                      ;
  143.         ;-------------------------------;
  144. @@4:    lodsb    
  145.     or    al,al
  146.     jz    @@7
  147.     jns    @@6
  148.     sub    al,81h
  149.         mov     ds:a_chdelay[bx],al
  150.     lodsb
  151. @@6:    mov    dl,al
  152.     and    ax,15
  153.     mov    bp,ax
  154.     add    bp,bp
  155.         mov     ax,ds:a_note_table[bp]
  156.     shr    dl,2
  157.     and    dl,not 3
  158.     add    ah,dl
  159.     call    a_playnote
  160.         mov     al,ds:a_chdelay[bx]
  161.         mov     ds:a_chdelaycnt[bx],al
  162.         mov     ds:[di],si
  163. @@2:    add    di,4
  164.     inc    bx
  165.         loop    @@13
  166. @@0:    ret
  167. @@7:    mov     si,ds:[di+2]
  168.     jmp    @@4
  169. a_dorow ENDP
  170.  
  171.